package com.qn.example.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import javafx.scene.Node;

import java.util.UUID;

public class UUIDUtils {
    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-","");
    }

    public static Integer getUUIDInOrderId(){
        Integer orderId=UUID.randomUUID().toString().hashCode();
        orderId = orderId < 0 ? -orderId : orderId; //String.hashCode() 值会为空
        return orderId;
    }


    public static void main(String[] args){
        for (int i = 0; i<100; i++) {
            System.out.println(UUIDUtils.getUUIDInOrderId());
        }
    }

    public static Long getLongId(){
        long workerId = 1L;
        long datacenterId = 1L;
        Snowflake snowflake = IdUtil.createSnowflake(workerId, datacenterId);
        return snowflake.nextId();
    }
}